(in-package :cl-daisyui)


;; https://daisyui.com/components/checkbox/
(defmacro checkbox (class &optional (checked t) &rest attrs)
  ;; If there's a label, place is in the end of attrs
  `(spinneret:with-html
     (:input :type "checkbox"
             :checked ,checked
             :class ,class
             ,@attrs)))

;; https://daisyui.com/components/file-input/
(defmacro file-input (class &rest attrs)
  `(spinneret:with-html
     (:input :type "file"
             :class ,class
             ,@attrs)))

;; https://daisyui.com/components/radio/
(defmacro radio (class name &optional (checked nil) &rest attrs)
  `(spinneret:with-html
     (:input :type "radio"
             :name ,name
             :class ,class
             :checked ,checked
             ,@attrs)))

;; https://daisyui.com/components/select/
(defmacro select-option (label &optional (disabled nil) (selected nil) &rest attrs)
  `(spinneret:with-html
     (:option :disabled ,disabled :selected ,selected ,label ,@attrs)))

(defmacro select (class options &rest attrs)
  `(spinneret:with-html
     (:select :class ,class
       ,@attrs
       ,@options)))

;; https://daisyui.com/components/input/
(defmacro input (class &optional (type "text") (placeholder "") &rest attrs)
  `(spinneret:with-html
     (:input :type ,type :class ,class :placeholder ,placeholder ,@attrs)))

;; https://daisyui.com/components/textarea/
(defmacro textarea (class &optional (placeholder "") &rest attrs)
  `(spinneret:with-html
     (:textarea :class ,class :placeholder ,placeholder ,@attrs)))

;; https://daisyui.com/components/toggle/
(defmacro toggle (class &optional (checked t) &rest attrs)
  `(spinneret:with-html
     (:input :type "checkbox"
         :class ,class
         :checked ,checked
         ,@attrs)))
